#define ElemType int
#define MaxSize 100

typedef struct //顺序栈
{
    ElemType data[MaxSize]; //存放在栈中的元素
    int top;                //栈顶指针
} SqStack;

void InitStack(SqStack &S) //顺序栈的初始化
{
    S.top = -1; //初始化栈顶指针为-1
}

bool StackEmpty(SqStack S) //判栈空
{
    if (S.top == -1) //栈空
        return true;
    else
        return false; //非空
}

bool Push(SqStack &S, ElemType x) //进栈
{
    if (S.top == MaxSize - 1) //栈满，报错(返回false)
        return false;
    S.data[++S.top] = x; //入栈(指针先加后用)
    return true;
}

ElemType Pop(SqStack &S) //出栈
{
    return S.data[S.top--];
}

ElemType GetTop(SqStack S) //读栈顶元素
{
    return S.data[S.top];
}